#pragma once
#include "afn0dbase.h"

#pragma pack(1)
class ActiveAfn0df7 : public Afn0dfbase
{
public:
	Td_d _time;
public:
	ActiveAfn0df7(uint16_t pn = 0)
	:Afn0dfbase(7, pn)
	{
	}
	Mapss& get(Mapmss& mss)const 
	{
		Mapss& m = mss[(int)pnfn];
	   	m["Fn"]   = Fn();
	   	m["Pn"]   = Fn();
	   	m["time"] = _time.toStringU();
		return m;
	}
	inline uint16_t length(void)const
	{
		return sizeof(*this);
	}
};

class PasiveAfn0df7 : public Afn0dfbase
{
public:
	enum{RATE_MIN = 1, RATE_MAX = 12};
	PasiveAfn0df7(uint16_t pn=0):Afn0dfbase(7, pn),_rate(RATE_MAX){}
public:
	Td_d frozTime;
	Td_c copyTime;
	uint8_t _rate;
	CommonA23 reverseTotalActiveMaxDemand;
	CommonA23 reverseActiveMaxDemand[RATE_MAX];
	CommonA17 reverseTotalActiveMaxDemandTime;
	CommonA17 reverseActiveMaxDemandTime[RATE_MAX];
	CommonA23 reverseTotalReactiveMaxDemand;
	CommonA23 reverseReactiveMaxDemand[RATE_MAX];
	CommonA17 reverseTotalReactiveMaxDemandTime;
	CommonA17 reverseReactiveMaxDemandTime[RATE_MAX];
public:
	inline Mapss& get(Mapmss& mss)const
	{
		Mapss& m = mss[(int)pnfn];
		return m;
	}
	inline uint16_t length(void)const
	{
		if(_rate >= RATE_MIN && _rate <= RATE_MAX)
		{
			return sizeof(PasiveAfn0df7)
				 - (RATE_MAX - _rate) * sizeof(CommonA23) * 2
				 - (RATE_MAX - _rate) * sizeof(CommonA17) * 2
				 ;
		}
	}
	inline void rate(uint8_t r)
	{
		if(r >= RATE_MIN && r <= RATE_MAX)
		{
			_rate = r;
		}
	}
};
#pragma pack(0)
